﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectSEAJunction.h
 * @brief   Graph object base for SEA junction data.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-13
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTION_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTION_H__

#include "FITKAcousticsVTKGraphObject3D.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkUnstructuredGrid;
class vtkPoints;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKAbstractJunction;
}

namespace Exchange
{
    /**
     * @brief   Graph object base for 'SEA junction'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-13
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectSEAJunction : public FITKAcousticsVTKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectSEAJunction, FITKAcousticsVTKGraphObject3D);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectSEAJunction);

    public:
        /**
         * @brief   Constructor.
         * @param   jPoint: The junction point data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        FITKAcousticsVTKGraphObjectSEAJunction(Acoustics::FITKAbstractJunction* junction);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual ~FITKAcousticsVTKGraphObjectSEAJunction();

        /**
         * @brief   Update all graph actors.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Highlight the graph actors.[virtual][override]
         * @param   type: The shape type need to be highlighted[default]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void highlight(FITKAcousticsVTKCommons::ShapeType type = FITKAcousticsVTKCommons::ShapeTypeNone, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void disHighlight() override;

        /**
         * @brief   Advanced highlight mode for highlighting part of the graph actors.[virtual][override]
         * @param   type: The type of the model need to be highlighted
         * @param   indice: The given indice of the model component need to be highlight
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void advanceHighlight(FITKAcousticsVTKCommons::ShapeType type, QVector<int> indice, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors if the graph object is in advanced highlighting mode.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void disAdvanceHighlight() override;

        /**
         * @brief   Set if the graph object pickable mode.[virtual][override]
         * @param   mode: The pickable mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void setPickMode(FITKAcousticsVTKCommons::ShapePickMode mode) override;

        /**
         * @brief   Get the VTK mesh grid by the given mesh type.[virtual][override]
         * @param   type: The shape's VTK mesh type
         * @return  The vtkDataSet object of the given type of mesh
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual vtkDataSet* getMesh(FITKAcousticsVTKCommons::ShapeType type) override;

    protected:
        /**
         * @brief   Intialize.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void init();

        /**
         * @brief   Generate the vtkDataSet for the junction.[pure virtual]
         * @param   junction: The junction data
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual bool generateDataSet(Acoustics::FITKAbstractJunction* junction) = 0;

        /**
         * @brief   Generate the actor with the junction data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void generateGraph();

        /**
         * @brief   Get the SEA node list from the data object.
         * @return  The SEA nodes data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        Acoustics::FITKAcousticsDiscNodeList* getSEANodesData();

        /**
         * @brief   Clear all vtk data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void resetVtkData();
        
        /**
         * @brief   Update the color by the enable flag.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void updateColorByEnableFlag();

        /**
         * @brief   Update the glyph size by the global runtime settings.[pure virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        virtual void updateGlyphSizeByRatio() = 0;

        /**
         * @brief   Get the visibility of SEA junctions with runtime settings.
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        bool getGlobalSEAJunctionsVisibility();

    protected:
        /**
         * @brief   The grid data for the junction.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkUnstructuredGrid* m_ugrid{ nullptr };

        /**
         * @brief   The points of the SEA nodes.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkPoints* m_points{ nullptr };

        /**
         * @brief   The actor for the junction grid.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        FITKAcousticsVTKGraphActor* m_fActor{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTION_H__
